<?php use app\commands\front\NavWidget; ?>
<?php NavWidget::begin(); ?>
<?php NavWidget::end();
$type = Yii::$app->request->get('type');
if ($type == 2) {
    $key = 'read';
} else {
    $key = 'listen';
}
?>
<link rel="stylesheet" href="/cn/css/mock/result.css">
<section class="resultCover" id="resultCover">
    <?php if ($type == 5) { ?>
        <!--全科模考-->
        <div class="completeResult">
            <div class="completeBpx">
                <p class="testName"><img src="<?php echo $data['user']['image'] == false ? 'https://file.viplgw.cn/ui/thinku-ielts-new/images/user/default@2x.png' : $data['user']['image'] ?>"
                                         alt=""><?php echo $data['user']['userName'] ?></p>

                <p class="testTitle"><?php echo $name ?> <span>模考时间：<?php echo $data['time'] ?></span></p>

                <div class="testBox">
                    <div class="bgColor">科目</div>
                    <div class="bgColor">听力</div>
                    <div class="bgColor">阅读</div>
                    <div class="bgColor">写作</div>
                    <div class="bgColor">得分/耗时</div>
                    <div class="bgColor">分数</div>
                    <div><?php echo $data['listen']['score']['score'] ?></div>
                    <div><?php echo $data['read']['score']['score'] ?></div>
                    <div><?php echo  count(explode(' ', $data['write']['son'][0]['userAnswer']))>1&& count(explode(' ', $data['write']['son'][1]['userAnswer']))>1?'Done':'Unfinished'; ?></div>
                    <div><?php echo $data['totalScore']?></div>
                    <div class="bgColor">耗时</div>
                    <div><?php echo $data['listen']['time']['time'] ?></div>
                    <div><?php echo $data['read']['time']['time'] ?></div>
                    <div><?php echo $data['write']['time']['time'] ?></div>
                    <div><?php echo $data['allTime'] ?></div>
                </div>
            </div>
            <div class="completeBpx">
                <p class="testTitle">模考记录</p>
                <div class="recordType">
                    <a href="javascript:;" :class="type == 1?'on':''" @click="recordChange(1)">听力</a>
                    <a href="javascript:;" :class="type == 2?'on':''" @click="recordChange(2)">阅读</a>
                    <a href="javascript:;" :class="type == 3?'on':''" @click="recordChange(3)">写作</a>
                </div>
                <!--阅读和听力一样-->
                <div v-if="type == 1" class="recordBox">
                    <div class="bgColor">题目小节</div>
                    <div class="bgColor">全部题目</div>
                    <div class="bgColor">答对题目</div>
                    <div class="bgColor">答错题目</div>
                    <div class="bgColor">未答题目</div>
                    <div class="bgColor">正确率</div>
                    <?php foreach ($data['listen']['part'] as $k => $v) { ?>
                        <div class="bgColor">Part <?php echo $k + 1 ?></div>
                        <div><?php echo $v['total'] ?></div>
                        <div><?php echo $v['correct'] ?></div>
                        <div><?php echo $v['error'] ?></div>
                        <div><?php echo $v['noDo'] ?></div>
                        <div><?php echo $v['rate'] ?></div>
                    <?php } ?>
                    <div class="bgColor">总体</div>
                    <div><?php echo $data['listen']['totalTotal'] ?></div>
                    <div><?php echo $data['listen']['totalCorrect'] ?></div>
                    <div><?php echo $data['listen']['totalError'] ?></div>
                    <div><?php echo $data['listen']['totalNoDo'] ?></div>
                    <div><?php echo $data['listen']['Rate'] ?></div>
                </div>
                <!--阅读-->
                <div v-if="type == 2" class="recordBox">
                    <div class="bgColor">题目小节</div>
                    <div class="bgColor">全部题目</div>
                    <div class="bgColor">答对题目</div>
                    <div class="bgColor">答错题目</div>
                    <div class="bgColor">未答题目</div>
                    <div class="bgColor">正确率</div>
                    <?php foreach ($data['read']['part'] as $k => $v) { ?>
                        <div class="bgColor">Part <?php echo $k + 1 ?></div>
                        <div><?php echo $v['total'] ?></div>
                        <div><?php echo $v['correct'] ?></div>
                        <div><?php echo $v['error'] ?></div>
                        <div><?php echo $v['noDo'] ?></div>
                        <div><?php echo $v['rate'] ?></div>
                    <?php } ?>
                    <div class="bgColor">总体</div>
                    <div><?php echo $data['read']['totalTotal'] ?></div>
                    <div><?php echo $data['read']['totalCorrect'] ?></div>
                    <div><?php echo $data['read']['totalError'] ?></div>
                    <div><?php echo $data['read']['totalNoDo'] ?></div>
                    <div><?php echo $data['read']['Rate'] ?></div>
                </div>
                <!--写作-->
                <div v-if="type == 3" class="writeBox">
                    <div class="bgColor">Part 1</div>
                    <div class="writeContent">
                        <p>建议用时</p>
                        <span>20min</span>

                        <p class="realTime">实际用时</p>
                        <span><?php echo floor($data['write']['son'][0]['time'] / 60) . 'm' . ($data['write']['son'][0]['time'] % 60) . 's' ?></span>
                    </div>
                    <div class="writeContent">
                        <p>建议词数</p>
                        <span>150</span>

                        <p class="realTime">实际词数</p>
                        <span><?php echo $data['write']['son'][0]['userAnswer'] != false ? count(explode(' ', $data['write']['son'][0]['userAnswer'])) : 0 ?></span>
                    </div>
                    <div class="bgColor">Part 2</div>
                    <div class="writeContent">
                        <p>建议用时</p>
                        <span>20min</span>

                        <p class="realTime">实际用时</p>
                        <span><?php echo floor($data['write']['son'][1]['time'] / 60) . 'm' . ($data['write']['son'][1]['time'] % 60) . 's' ?></span>
                    </div>
                    <div class="writeContent">
                        <p>建议词数</p>
                        <span>250-280</span>

                        <p class="realTime">实际词数</p>
                        <span><?php echo $data['write']['son'][1]['userAnswer'] != false ? count(explode(' ', $data['write']['son'][1]['userAnswer'])) : 0 ?></span>
                    </div>
                </div>
            </div>
            <div class="questionBox" v-if="type!=3">
                <p>答题记录总览</p>
                <a href="javascript:;" :class="typeCorrect == 1?'on':''" @click="changeCorrect(1)">全部</a>
                <a href="javascript:;" :class="typeCorrect == 2?'on':''" @click="changeCorrect(2)">错题</a>
            </div>
            <!--听力-->
            <div class="questionNum" v-if="type == 1">
                <?php foreach ($data['listen']['son'] as $k => $v) { ?>
                    <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=<?php echo $key?>&content_id=<?php echo $v['content_id']?>" class="<?php echo $v['judge'] === '0' ? 'red' : ($v['judge'] == 1 ? 'green' : 'normal') ?>"><?php echo $k + 1 ?></a>
                <?php } ?>
            </div>
            <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=listen" v-if="type == 1" class="questionDetailBtn">听力做题详情</a>
            <!--阅读-->
            <div class="questionNum" v-if="type == 2">
                <?php foreach ($data['read']['son'] as $k => $v) { ?>
                    <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=<?php echo $key?>&content_id=<?php echo $v['content_id']?>" class="<?php echo $v['judge'] === '0' ? 'red' : ($v['judge'] == 1 ? 'green' : 'normal') ?>"><?php echo $k + 1 ?></a>
                <?php } ?>
            </div>
            <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=read" v-if="type == 2" class="questionDetailBtn">阅读做题详情</a>
            <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=write" v-if="type == 3" class="questionDetailBtn">写作做题详情</a>
        </div>
    <?php } else { ?>
        <!--阅读和听力一样-->
        <div class="completeResult">
            <div class="completeBpx colorSpecail">
                <p class="testName"><img src="<?php echo $data['user']['image'] == false ? 'https://file.viplgw.cn/ui/thinku-ielts-new/images/user/default@2x.png' : $data['user']['image'] ?>"
                                         alt=""><?php echo $data['user']['userName'] ?></p>

                <p class="testTitle"><?php echo $name ?> <span>模考时间：<?php echo $data['time'] ?></span></p>

                <p class="testTj">
                    <span class="tjName">耗时</span>
                    <span class="tjName">得分</span>
                    <span><?php echo $data['allTime'] ?></span>
                    <span><?php echo $data[$key]['score']['score'] ?></span>
                </p>
            </div>
            <div class="completeBpx">
                <p class="testTitle"><?php echo $type == 1 ? '听力' : '阅读' ?>模考记录</p>
                <!--阅读和听力一样-->
                <div class="recordBox">
                    <div class="bgColor">题目小节</div>
                    <div class="bgColor">全部题目</div>
                    <div class="bgColor">答对题目</div>
                    <div class="bgColor">答错题目</div>
                    <div class="bgColor">未答题目</div>
                    <div class="bgColor">正确率</div>
                    <?php foreach ($data[$key]['part'] as $k => $v) { ?>
                        <div class="bgColor"><?php echo $type == 1 ? 'Part' : 'Passage' ?> <?php echo $k + 1 ?></div>
                        <div><?php echo $v['total'] ?></div>
                        <div><?php echo $v['correct'] ?></div>
                        <div><?php echo $v['error'] ?></div>
                        <div><?php echo $v['noDo'] ?></div>
                        <div><?php echo $v['rate'] ?></div>
                    <?php } ?>
                    <div class="bgColor">总体</div>
                    <div><?php echo $data[$key]['totalTotal'] ?></div>
                    <div><?php echo $data[$key]['totalCorrect'] ?></div>
                    <div><?php echo $data[$key]['totalError'] ?></div>
                    <div><?php echo $data[$key]['totalNoDo'] ?></div>
                    <div><?php echo $data[$key]['Rate'] ?></div>
                </div>
            </div>
            <div class="questionBox">
                <p>答题记录总览</p>
                <a href="javascript:;" :class="typeCorrect == 1?'on':''" @click="changeCorrect(1)">全部</a>
                <a href="javascript:;" :class="typeCorrect == 2?'on':''" @click="changeCorrect(2)">错题</a>
            </div>
            <div class="questionNum">
                <?php foreach ($data[$key]['son'] as $k => $v) { ?>
                    <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=<?php echo $key?>&content_id=<?php echo $v['content_id']?>" class="<?php echo $v['judge'] === '0' ? 'red' : ($v['judge'] == 1 ? 'green' : 'normal') ?>"><?php echo $k + 1 ?></a>
                <?php } ?>
            </div>

            <a href="/mock/detail.html?resultid=<?php echo $data['resultid']?>&subject=<?php echo $key?>" class="questionDetailBtn"><?php echo $type == 1 ? '听力' : '阅读' ?>做题详情</a>
        </div>
    <?php } ?>
</section>
<script>
    window.reslut = new Vue({
        el: '#resultCover',
        data() {
            return {
                type: 1,
                typeCorrect: 1,
            }
        },
        created() {

        },
        methods: {
            recordChange(type) {
                this.type = type
                this.typeCorrect = 1
                $('.normal').show()
                $('.green').show()
                $('.red').show()
            },
            changeCorrect(typeCorrect) {
                this.typeCorrect = typeCorrect
                if (this.typeCorrect == 1) {
                    $('.normal').show()
                    $('.green').show()
                    $('.red').show()
                } else {
                    $('.normal').hide()
                    $('.green').hide()
                    $('.red').show()
                }
            }
        },
    });
</script>
